package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.dto.MsgDto;
import com.yami.shop.bean.model.Msg;
import com.yami.shop.bean.model.MsgSub;
import com.yami.shop.dao.MessageMapper;
import com.yami.shop.dao.MsgSubMapper;
import com.yami.shop.service.MsgService;
import com.yami.shop.dao.MsgMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

/**
* @author rows
* @description 针对表【tz_msg】的数据库操作Service实现
* @createDate 2023-04-11 09:32:32
*/
@Service
public class MsgServiceImpl extends ServiceImpl<MsgMapper, Msg>
    implements MsgService{
    @Autowired
    private MsgMapper msgMapper;
    @Autowired
    private MsgSubMapper msgSubMapper;

    @Override
    public IPage selectPage(Page<Msg> page, MsgDto msg) {
        return msgMapper.selectPage(page,msg);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void remove(Serializable id) {
        msgMapper.deleteById(id);
        msgSubMapper.delete(new LambdaQueryWrapper<MsgSub>().eq(MsgSub::getMsgId,id));
    }
}




